// JavaScript Document
//<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"> < /script>
/*    
循环显示一些元素
使用方式

cv = new CycleView();
cv.push_view("#id1");
cv.push_view("#id2");
cv.push_view("#id3");
cv.push_view("#id4");
cv.update_view();


上一个：cv.previous();
下一个：cv.next();
*/

function CycleView()
{
	
	this.view_ids = new Array();
	this.show_index = 0;
	this.push_view = function(id)
	{
		this.view_ids.push(id);
		//this.update_view();
	}
	
	this.update_view = function()
	{
		for(i=0; i < this.view_ids.length; i++)
		{
			e = $(this.view_ids[i]);
			if(e)
			{
				
				if(i == this.show_index)
				{
					e.show();
				}
				else
				{
					e.hide();
				}
			}
		}
		//alert("" + this.show_index + ":" + this.view_ids.length);
	}
	
	this.previous = function()
	{
		this.show_index--;
		if(this.show_index < 0)
		{
			this.show_index = this.view_ids.length - 1;
		}
		this.update_view();
	}
	
	this.next = function()
	{
		this.show_index++;
		if(this.show_index >= this.view_ids.length)
		{
			this.show_index = 0;
		}
		this.update_view();
	}
}